package com.example.freewood.smartsecurity_manager.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.freewood.smartsecurity_manager.R;
import com.example.freewood.smartsecurity_manager.activity.Device.FindNewDevice;
import com.example.freewood.smartsecurity_manager.adapter.DeviceAdapter;
import com.melnykov.fab.FloatingActionButton;

/**
 * Created by FreeWood on 16/4/1.
 */
public class DeviceList extends Fragment {
    private ListView listView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_device, container, false);
        listView = (ListView) view.findViewById(R.id.list_device);
        DeviceAdapter deviceAdapter = new DeviceAdapter(getContext(), null);
        FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.device_fab);
        fab.attachToListView(listView);
        listView.setAdapter(deviceAdapter);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(), FindNewDevice.class));
            }
        });
        return view;
    }
}
